package com.offcn.service.impl;

import com.offcn.dao.impl.UserDaoImpl;
import com.offcn.entity.Paging;
import com.offcn.entity.User;
import com.offcn.service.UserService;

import java.sql.SQLException;
import java.util.List;

public class UserServiceImpl implements UserService {
    //登录的方法
    private UserDaoImpl daoImpl = new UserDaoImpl();
    public User login(String username, String password) throws SQLException {
        User user = daoImpl.login(username,password);
        return user;
    }

    //查询总条数的方法
    public int queryTotalCount(String usernameSearch) throws SQLException {
        int totalCount = daoImpl.queryTotalCount(usernameSearch);
        return totalCount;
    }

    //查询并分页展示
    public List<User> findUserByPage(Paging page, String usernameSearch) throws SQLException {
        List<User> list = daoImpl.findUserByPage(page,usernameSearch);
        return list;
    }

    public int modifyUser(User user) throws SQLException {
        int row = daoImpl.modifyUser(user);
        return row;
    }

    //根据选择框所选进行删除，where id = ?
    /*public int DeleteAccordingSelection(String[] split) throws SQLException {
        int row = daoImpl.DeleteAccordingSelection(split);
        return row;
    }*/
    public int DeleteAccordingSelection(String delarr) throws SQLException {
        int row = daoImpl.DeleteAccordingSelection(delarr);
        return row;
    }

    public int addUser(User user) throws SQLException {
        int row = daoImpl.addUser(user);
        return row;
    }
}
